import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ContainerLearn extends StatelessWidget {
  const ContainerLearn({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("container"),
        ),
        body: Container(
          height: 500,
          width: 500,
          decoration: BoxDecoration(
              border: Border.all(color: Colors.pink),
              //设置圆角
              borderRadius: BorderRadius.circular(12),
              //颜色渐变
              gradient:
                  LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [Colors.red, Colors.yellow]),
              //设置背景
              image: DecorationImage(
                  //只接受AssertImage
                  image: AssetImage("images/picture.jpg"),
                  fit: BoxFit.cover)),
          child: Column(
            children: [


              Container(
                decoration: BoxDecoration(
                  border: Border.all(color: Colors.black),
                ),
                child: Text("不设置高宽和孩子节点一样大"),
              ),
              Container(
                color: Colors.red,
              ),
              Text('上面的container不显示，没有高宽以及子节点在父节点无盒子限制的时候就会为0不显示,有限制则会撑满最大限制'),


              Expanded(
                  child: ListView(
                children: [
                  Row(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Container(
                        color: Colors.lightBlueAccent,
                        child: Text("借助row或者column来解决listview宽度问题"),
                      )
                    ],
                  ),
                  Container(
                    //宽无效
                    width: 100,
                    margin: EdgeInsets.only(top: 10),
                    color: Colors.red,
                    child: Text(
                      "listView滚动方向为vertical，内部组件设置宽度无效，都是铺满屏幕宽度,"
                      "滚动方向为horizontal,内部组件设置高度无效，都会默认铺满屏幕高度",
                      style: TextStyle(color: Colors.white),
                    ),
                  ),
                  Column(
                    children: [
                      Container(
                        margin: EdgeInsets.only(top: 10),
                        color: Colors.red,
                        height: 50,
                        child: Text(
                          "column可以打破listview的限制",
                          style: TextStyle(color: Colors.white),
                        ),
                      )
                    ],
                  )
                ],
              ))
            ],
          ),
        ));
  }
}
